Page({
  data: {
    userPoints: 1280,
    showRulesPopup: false,
  },

  showRules() {
    this.setData({
      showRulesPopup: true
    });
  },

  hideRules() {
    this.setData({
      showRulesPopup: false
    });
  },

  completeTask(e) {
    const taskId = e.currentTarget.dataset.id;
    const tasks = this.data.dailyTasks.map(task => {
      if (task.id === taskId && !task.completed) {
        // 完成任务逻辑
        wx.showToast({
          title: '获得' + task.points + '积分',
          icon: 'success'
        });
        return { ...task, completed: true };
      }
      return task;
    });
    this.setData({
      dailyTasks: tasks
    });
  },

  navigateToExchange() {
    wx.navigateTo({
      url: '/pages/points-exchange/index'
    });
  },

  navigateToTask() {
    wx.navigateTo({
      url: '/pages/points-task/index'
    });
  }
}); 